<template>
    <yd-list theme="4" class="list-page">
        <yd-list-item v-for="(item,index) in list" :key="index" type="link"
                      :href="getUrlParam(item)" :class="{'select-shop':item.id ==params.shopId}">
            <span slot="title">{{item.shop_name}}</span>
            <yd-list-other slot="other">
                <div>
                    <div class="demo-list-price">{{item.address}}</div>
                    <div>
                        剩余数量：<span style="font-weight: bold;color: black">{{ item.num }}</span>
                    </div>
                </div>
                <div style="width: 2rem;text-align: end">
                    <div style="color:red;" v-if="item.isSub==1">{{ item.subTitle }}</div>
                    <div style="color:red;" v-else>{{ item.subTitle }}</div>
                </div>
            </yd-list-other>
        </yd-list-item>
    </yd-list>
</template>

<script type="text/babel">
import { shopList } from '@/api/kouzhao.js'

export default {
  data () {
    return {
      list: [],
      params: {}
    }
  },
  methods: {
    getShopList () {
      shopList().then(ret => {
        let result = ret.data
        if (result.errcode === 1001) {
          this.list = result.data
        } else {
          this.$dialog.alert({ mes: '没有数据！' })
        }
      })
    },
    getUrlParam (item) {
      let data = JSON.parse(JSON.stringify(this.params))
      data.shopId = item.id
      data.shopName = item.shop_name
      data.address = item.address
      data.catId = item.category
      return { name: 'shopPeople', params: data }
      //  if (item.isSub === 1) {
      // } else {
      //  return '#'
      // }
    },
    getYuYueTitle (catId) {
      let title = ''
      switch (catId) {
        case 1:
          title = '12:00后开始预约'
          break
        case 2:
          title = '12:30后开始预约'
          break
        case 3:
          title = '13:00后开始预约'
          break
        case 4:
          title = '13:30后开始预约'
          break
        case 5:
          title = '14:00后开始预约'
          break
        default:
          title = '可以预约'
      }
      return title
    }
  },
  mounted () {
    if (this.$route.params) {
      this.params = this.$route.params
    }
    console.log(this.$route)
    this.getShopList()
  }
}
</script>

<style scoped>
    .list-page >>> .yd-list-img {
        width: auto;
    }

    .list-page .yd-list-item {
        height: 2rem;
    }

    .select-shop >>> .yd-list-title {
        color: #0bb20c;
    }

    .select-shop >>> .yd-list-other {
        color: #0bb20c;
    }
</style>
